﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Simply.BusinessTier.Facade.Interface;
using Domain;
using Simply.DataTier.Repository.Interface;
using Simply.DataTier.Repository.Implementation;

namespace Simply.BusinessTier.Facade.Implementation
{
    public class StaticDataService : IStaticDataService
    {

        private IStaticDataRepository staticRepository;
        public StaticDataService(IStaticDataRepository staticRepository)
        {
            this.staticRepository = staticRepository;
        }

        public StaticDataService()
            : this( new StaticDataEFRepository())
        {
        }

        #region IStaticDataService Members

        public List<IndustryDO> GetAllIndustries()
        {
            return staticRepository.GetAllIndustries();
        }

        public List<StyleDO> GetAllStyles()
        {
            return staticRepository.GetAllStyles();
        }

        public List<ColorThemeDO> GetAllColorThemes()
        {
            return staticRepository.GetAllColorThemes();
        }

        public List<TagDO> GetAllTags()
        {
            return staticRepository.GetAllTags();
        }

        public List<DesignGroupDO> GetAllDesignGroups()
        {
            return staticRepository.GetAllDesignGroups();
        }
        public List<PrintMediaTypeDO> GetAllPrintMediaTypes()
        {
            return staticRepository.GetAllPrintMediaTypes();
        }

        public List<FontDO> GetAllFonts()
        {
            return staticRepository.GetAllFonts();
        }

        public int GetProductCountForStyle(int styleId, string productType)
        {
            return staticRepository.GetProductCountForStyle(styleId, productType);
        }

        public int GetProductCountForIndustry(int industryId, string productType)
        {
            return staticRepository.GetProductCountForIndustry(industryId, productType);
        }

        public int GetProductCountForColor(int colorId, string productType)
        {
            return staticRepository.GetProductCountForColor(colorId, productType);
        }

        public List<PrintMethodDO> GetMediaPrintMethods(string mediaCode)
        {
            return this.GetPrintMethodsByMediaType(this.GetPrintMediaByCode(mediaCode).Type.Code);
        }

        public FontDO GetFontById(int fontId)
        {
            return staticRepository.GetFontById(fontId);
        }

        public StyleDO GetStyleById(int styleId)
        {
            return staticRepository.GetStyleById(styleId);
        }

        public IndustryDO GetIndustryById(int industryId)
        {
            return staticRepository.GetIndustryById(industryId);
        }

        public PrintMediaDO GetPrintMediaByCode(string mediaCode)
        {
            return staticRepository.GetPrintMediaByCode(mediaCode);
        }

        public List<PrintMethodDO> GetPrintMethodsByMediaType(string mediaType)
        {
            List<PrintMethodDO> methodModels = new List<PrintMethodDO>();
            List<PrintMethodDO> methods = staticRepository.GetPrintMethodsByMediaType(mediaType);
            foreach (var meth in methods)
            {
                methodModels.Add(new PrintMethodDO()
                {
                    Code = meth.Code,
                    NameEn = meth.NameEn,
                    NameAm = meth.NameAm,
                    NameRu = meth.NameRu,

                    DescriptionEn = meth.DescriptionEn,
                    DescriptionAm = meth.DescriptionAm,
                    DescriptionRu = meth.DescriptionRu,
                    BothSide = meth.BothSide,
                    Duration = meth.Duration,
                    AvailableFrom = meth.AvailableFrom
                });
            }
            return methodModels;
        }

        public List<IndustryDO> GetProductActiveIndustries(string productType)
        {
            throw new NotImplementedException();
        }

        public List<StyleDO> GetProductActiveStyles(string productType)
        {
            throw new NotImplementedException();
        }

        public List<TagDO> GetProductActiveTags(string productType)
        {
            throw new NotImplementedException();
        }

        public List<ColorThemeDO> GetProductActiveColorThemes(string productType)
        {
            throw new NotImplementedException();
        }


        public int CreateStyle(StyleDO style)
        {
            return staticRepository.CreateStyle(style);
        }

        public int CreateIndustry(IndustryDO industry)
        {
            return staticRepository.CreateIndustry(industry);
        }

        public int CreateColorTheme(ColorThemeDO colorTheme)
        {
            return staticRepository.CreateColorTheme(colorTheme);
        }

        public long CreateTag(TagDO tag)
        {
            return staticRepository.CreateTag(tag);
        }

        public void CreatePrintMediaType(PrintMediaTypeDO type)
        {
            staticRepository.CreatePrintMediaType(type);
        }
        public long CreateDesignGroup(DesignGroupDO design)
        {
            return staticRepository.CreateDesignGroup(design);
        }

        public int CreateFont(FontDO font)
        {
            return staticRepository.CreateFont(font);
        }

        #endregion
    }
}
